import request from '@/utils/request.ts';
import type { AttrInfoListResData, Category, AttrInfo } from './type.ts';
import { ResponseData } from '../type.ts';

// 平台属性相关接口
enum API {
  GET_ATTRINFO_LIST = '/admin/product/attrInfoList',
  SAVE_ATTRINFO = '/admin/product/saveAttrInfo',
  DELETE_ATTRINFO = '/admin/product/deleteAttr'
}

// 获取平台属性列表
export const reqGetAttrInfoList = ({
  category1Id,
  category2Id,
  category3Id
}: Category) =>
  request.get<any, AttrInfoListResData>(
    `${API.GET_ATTRINFO_LIST}/${category1Id}/${category2Id}/${category3Id}`
  );

// 添加或更新平台属性
export const reqSaveAttrInfo = (data: AttrInfo) =>
  request.post<any, ResponseData>(API.SAVE_ATTRINFO, data);

// 删除平台属性
export const reqDeleteAttrInfo = (attrId: number) =>
  request.delete<any, ResponseData>(`${API.DELETE_ATTRINFO}/${attrId}`);
